$(document).ready(function(){	
});

function checkLogin(){
//	var vcode = $('#VALIDATE_CODE').val();
//	if(vcode.length == 0){
//		alert("验证码不能为空！");
//		return false;
//	}
	var account = $('#USER_NAME').val();
	if(account.length == 0){
		alert("用户名不能为空！");
		return false;
	}
	var pwd = $('#PASSWORD').val();
	if(pwd.length == 0){
		alert("密码不能为空！");
		return false;
	}
	return true;
}

function resetText(){
	$('#LOGIN_NAME').val('');
	$('#PASSWORD').val('');
	//$('#VALIDATE_CODE').val('');
}

//
function login() {
	//$.ajaxSetup({contentType:'application/x-www-form-urlencoded;charset=utf-8'});
	if(checkLogin()){
		$.post(foxit.common.path+'/UserLogin.do',
			{
				USER_NAME : $('#USER_NAME').val(),
				PASSWORD : $('#PASSWORD').val()
				//VALIDATE_CODE : $('#VALIDATE_CODE').val()
			}, function(data){
				if (!data.success) {
					alert(data.msg);
					//drawValidateCode();
				} else {
					var userid = data.userid;
					console.log(userid);
					window.location.href = foxit.common.path + '/list.html';
				}
			}, 'json'
		);
	}
}

//
//function drawValidateCode() {
//	var vc = new ValidateCode('validateCode.jsp',58,18,4);
//	vc.applyTo('validateCode');
//}

function hotkey(evt){
	var a = window.event ? window.event.keyCode : evt.which;
	if(a == 13) {
		login();
	}
}
document.onkeydown = hotkey;